<?php

namespace app\admin\validate;

use think\Validate;

class User extends Validate
{
    /**
     * 验证规则
     */
    protected $rule = [
        'username'  => 'length:3,50|unique:user,username',
        'nickname'  => 'length:3,50|unique:user,nickname',
        'email'     => 'email',
        'mobile'    => 'mobile',
        'password'  => 'length:6,30',
    ];
    /**
     * 提示消息
     */
    protected $message = [
        'username.length'  => '用戶名必须3-50个字符',
        'password.length'  => '密码必须6-30个字符',
        'email.email'      => '请填写正确的邮箱',
        'mobile.mobile'    => '请填写正确的手机号码'
    ];
    /**
     * 验证场景
     */
    protected $scene = [
        'add'  => [],
        'edit' => [],
    ];
    public function __construct(array $rules = [], $message = [], $field = [])
    {
        $this->field = [
            'username' => __('Username'),
            'nickname' => __('Nickname'),
        ];
        // parent::__construct($rules, $message, $field);
    }
}
